﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using FinPlusAssembler;
using FinPlusInterfaces;

namespace FinPlusBaseCore
{
    public static class PodsExtension
    {
        public static string Display(this IPods pods, BeanField fieldType, string[] displayFields, string[] displayOrder)
        {
            var res1 = pods.Values.Select(f => (new KeyValuePair<string, string>(f.SortKey(displayOrder ?? new[] { "Id" }), f.Display(displayFields ?? new[] { "Id" })))).ToList();

            var res2 = string.Join("%", res1.OrderBy(kvp => kvp.Key).Select(kvp => kvp.Value).ToArray());

            return res2;
        }
    }
}
